<template>
  <div>
    <van-tabbar
      active-color="#f66"
      inactive-color="#666"
      :route="true"
     >
    <van-tabbar-item
      to="/home">
        <span>首页</span>
        <template #icon="props">
          <van-icon class="iconfont" class-prefix="icon" name="home"/>
        </template>
    </van-tabbar-item>
    <van-tabbar-item
      to="/cate">
        <span>分类</span>
        <template #icon="props">
          <van-icon class="iconfont" class-prefix="icon" name="category"/>
        </template>
    </van-tabbar-item>
    <van-tabbar-item
      to="/cart"
      :badge="items.length?items.length:''"
      >
        <span>购物车</span>
        <template #icon="props">
          <van-icon class="iconfont" class-prefix="icon" name="cart"/>
        </template>
      </van-tabbar-item>
    <van-tabbar-item
      to="/mine">
        <span>我的</span>
        <template #icon="props">
          <van-icon class="iconfont" class-prefix="icon" name="mine"/>
        </template>
      </van-tabbar-item>
  </van-tabbar>
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
  computed: {
    ...mapState({
      items: (state) => state.cart.items
    })
  }
}
</script>

<style lang="scss" scoped>

</style>
